package com.leetcode.August;


import java.util.List;
import java.util.Stack;

/**
 * @Description: 234. 回文链表
 * @Author: Mr.Fxy
 * @CreateTime: 2024-08-24 16:26
 */
public class LC234回文链表 {
    public boolean isPalindrome(ListNode head) {
        Stack<Integer> stack = new Stack<>();
        ListNode cur = head;
        while (cur != null){
            stack.push(cur.val);
            cur=cur.next;
        }
        while (head != null){
            if (head.val!=stack.pop())return false;
            head=head.next;
        }
        return true;
    }
}
